﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_ModifyUsername : System.Web.UI.Page
{
	private ColumnComponent clsColumnComp = new ColumnComponent();
	private int nColumnID;		// 当前栏目ID
	private int nLoginUserID;		// 登录的用户ID
	private UserComponent clsUserComp = new UserComponent();

	protected void Page_Load(object sender, EventArgs e)
	{
		if (!IsPostBack)
		{
			nColumnID = Convert.ToInt32(Request.QueryString["id"]);
			LabColumnName.Text = clsColumnComp.GetOneByID(nColumnID).Name;
		}

		nLoginUserID = Convert.ToInt32(Session["LoginUserID"].ToString());
		LabOldUsername.Text = clsUserComp.GetOneByID(nLoginUserID).Username;

		////////////////////////////////////////////////////////////////////////////////
		// 控件事件添加
		BtnModify.Click += new EventHandler(BtnModify_OnClick);		// 修改按钮
		////////////////////////////////////////////////////////////////////////////////
	}

	/// <summary>
	/// <para>功能描述：	修改</para>
	/// <para>输入参数：	</para>
	/// <para>返回值：	</para>
	/// <para>方法范围：	protected</para>
	/// <para>作者：	Tony Mucor</para>
	/// <para>日期：	2013-08-08</para>
	/// <para>备注：	</para>
	/// </summary>
	protected void BtnModify_OnClick(object sender, EventArgs e)
	{
		User clsModifyUser;
		int nModifyUserID;
		string strNewUsername;

		strNewUsername = TxtNewUsername.Text;
		nModifyUserID = nLoginUserID;
		clsModifyUser = clsUserComp.GetOneByID(nModifyUserID);
		clsModifyUser.Username = strNewUsername;
		if (clsUserComp.Modify(clsModifyUser))
		{
			ShowMessageAlert.ShowMessage("修改成功！");
			LabOldUsername.Text = strNewUsername;
			TxtNewUsername.Text = "";
		}
	}

}
